using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using LeisureCenter.Api;
using LeisureCenter.Core;
using LeisureCenter.BrowserItems;

namespace LeisureCenter.MenuItems
{
    public class FileSystemBookmarksSubmenuItem : BaseFileSystemMenuItem, IMenuItem
    {
        private FileSystemBookmark bookmark;

        public FileSystemBookmarksSubmenuItem(FileSystemBookmark bookmark)
        {
            this.bookmark = bookmark;
        }

        public override FileSystemBrowserFolderItem CreateRootFolder()
        {
            return new FileSystemBrowserFolderItem(this, null, new DirectoryInfo(bookmark.Path), null);
        }

        #region IMenuItem Membres

        public string Text { get { return bookmark.Name; } }
        public string IconName { get { return @"bookmarkFolder"; } }

        #endregion
    }

    public class FileSystemBookmarksMainMenuItem : IMenuItem
    {
        #region IMenuItem Membres

        public string Text
        {
            get { return @"Bookmarks"; }
        }

        public string IconName
        {
            get { return @"bookmark"; }
        }

        public void Execute()
        {
            ExecuteAgain();
        }

        public void ExecuteAgain()
        {
            List<IMenuItem> items = new List<IMenuItem>();
            foreach (FileSystemBookmark bookmark in Program.LeisureCenterInstance.Settings.FileSystemBookmarks)
            {
                items.Add(new FileSystemBookmarksSubmenuItem(bookmark));
            }
            IMenuItem[] itemsArray = new IMenuItem[items.Count];
            items.CopyTo(itemsArray);
            Program.LeisureCenterInstance.MenuManager.FillSubmenu(itemsArray);
        }

        public void OptionsExecute()
        {
        }

        #endregion
    }

    public class FileSystemBookmarksMainMenuItemsProvider : IMainMenuItemsProvider
    {
        IMenuItem[] items = new IMenuItem[] { new FileSystemBookmarksMainMenuItem() };

        #region IMainMenuItemsProvider Membres

        public IEnumerable<IMenuItem> Items
        {
            get { return items; }
        }

        #endregion
    }
}
